package box_server

import (
	"github.com/Amovement/password-box/pkg/dao"
	"github.com/Amovement/password-box/pkg/models"
)

func DeleteBox(box *models.Box) error {
	if err := dao.DeleteBox(box); err != nil {
		return err
	} else {
		return nil
	}
}

func CreateBox(box *models.Box) (*models.Box, error) {
	if box, err := dao.CreateBox(box); err != nil {
		return nil, err
	} else {
		return box, nil
	}
}

func ListBoxByUsername(username string) ([]*models.Box, error) {
	if boxs, err := dao.ListBoxsByUsername(username); err != nil {
		return nil, err
	} else {
		return boxs, nil
	}
}

func GetBoxById(id uint) (*models.Box, error) {
	if box, err := dao.GetBoxById(id); err != nil {
		return nil, err
	} else {
		return box, nil
	}
}
